﻿using MediatR;
using T_vehicle.API.Application.Command.AccidentCommand;
using T_vehicle.Infrastructure.Interfacec;

namespace T_vehicle.API.Application.CommandHandlers.AccidentCommandHandlers
{
    public class DelAccidentCommandHandlers:IRequestHandler<DelAccidentCommand,int>
    {
        private readonly IAccidentRepository accidentRepository;

        public DelAccidentCommandHandlers(IAccidentRepository accidentRepository)
        {
            this.accidentRepository = accidentRepository;
        }

        public async Task<int> Handle(DelAccidentCommand request, CancellationToken cancellationToken)
        {
            var list = await accidentRepository.GetModelAsync(request.AccidentId);
            list.IsDel = true;
            var res = await accidentRepository.UpdateAsync(list);
            return res;
        }
    }
}
